{include file="public/head"}

<style>
    .table input{
        border: none;
        outline: none;
        width: 100%;
        height: 100%;
        border-bottom: 1px solid black;
    }
</style>
<body>
<div id="wrapper">
    {include file="public/menu"}

    <div id="page-wrapper" class="gray-bg dashbard-1">
        {include file="public/nav"}
        <div class="row wrapper border-bottom white-bg page-heading">
            <div class="col-lg-10">
                <h2>支付密码</h2>
                <ol class="breadcrumb">
                    <li>
                        <a href="{:url('Index/index')}">主页</a>
                    </li>
                    <li>
                        <a>个人资料</a>
                    </li>
                    <li>
                        <strong>修改支付密码</strong>
                    </li>
                </ol>
            </div>
            <div class="col-lg-2">

            </div>
        </div>
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-sm-4">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>支付密码</h5>
                        </div>
                        <div>
                            <label for="upload" style="display: block">
                                <div class="ibox-content no-padding" style="text-align: center">
                                    <img alt="image" class="" src="/static/Admin/img/profile_small.jpg" style="width: 50%;border-radius: 50%">
                                    <input type="file" style="opacity: 0" id="upload">
                                </div>
                            </label>

                            <div class="ibox-content" style="text-align: center;border: none;margin: 2rem 0">
                                <p>{$UserInfo.username}</p>
                                <p>{$UserInfo.recommend_num}</p>
                            </div>
                            <div class="ibox-content profile-content">
<!--                                m-t-lg-->
                                <div class="row">
                                    <div class="col-sm-12" style="text-align: center">
                                        <h5><strong>{$UserInfo.level_name}</strong></h5>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="col-sm-8">
                    <div class="ibox">
                        <div class="ibox-content">
                            <div class="clients-list">
                                <ul class="nav nav-tabs">
                                    <li class="active"><a data-toggle="tab" href="#tab-1"><i class="fa fa-user"></i> 修改支付密码</a>
                                    </li>
                                </ul>
                                <div class="tab-content">
                                    <div id="tab-1" class="tab-pane active">
                                        <div class="full-height-scroll">
                                            <div class="table-responsive">
                                                <table class="table table-striped table-hover">
                                                    <tbody>
                                                        {if condition="$need eq 1"}
                                                        <tr>
                                                            <td>旧密码</td>
                                                            <td class="client-status"><input type="text" id="old_password" placeholder="请输入旧密码"></td>
                                                        </tr>
                                                        {/if}
                                                        <tr>
                                                            <td>新密码</td>
                                                            <td class="client-status"><input type="text" id="new_password" placeholder="请输入新密码"></td>
                                                        </tr>
                                                        <tr>
                                                            <td>确认密码</td>
                                                            <td class="client-status"><input type="text" id="sure_password" placeholder="请确认新密码"></td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                            </div>
                                            <div class="user-button">
                                                <div class="row">
                                                    <div class="col-sm-3">
                                                        <div class="btn btn-primary btn-sm btn-block" id="save">保存</div>
                                                    </div>
                                                    <div class="col-sm-3">
                                                        <div class="btn btn-default btn-sm btn-block" onclick="window.location.href = '{:url("UserInfo")}'">返回</div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        {include file="public/foot"}
    </div>
</div>
</div>
{include file="public/footer"}
<script src="/static/kuang/js/jquery.qrcode.min.js"></script>
<script>
    $(function(){$(".full-height-scroll").slimScroll({height:"100%"})});

    $('#save').on('click',function () {
        var old_password = $('#old_password').val();
        var new_password = $('#new_password').val();
        var sure_password = $('#sure_password').val();

        if ("{$need}" == '1'){
            if (old_password == ''){
                layer.msg('请输入原密码');
                return false;
            }
        }

        if (new_password == ''){
            layer.msg('请输入新密码');
            return false;
        }
        if (sure_password == ''){
            layer.msg('请再次输入新密码');
            return false;
        }

        if(new_password != sure_password){
            layer.msg('两次密码不一致');
            return false;
        }

        $.ajax({
            type: "post",
            url: "{:url('User/UserPassPay')}",
            data: {
                old_password: old_password,
                new_password: new_password,
            },
            dataType: "json",
            success: function (data) {
                if(data.status == 1){
                    layer.msg(data.message);
                    window.location.reload();
                }else{
                    layer.msg(data.message);
                }
            }
        });

    })
</script>
</body>
</html>
